package org.firebug.common.core.api;


/**
 * 接口数据响应
 * @author Felix
 */
public class Response<T> {
    public static final Response<Void> _200 = new Response(Meta._200); // 同步请求成功

    public static Response<Void> ok() {
        return Response._200;
    }

    public static <T> Response<T> ok(T data) {
        return new Response<>(Meta._200, data, null);
    }

    public static <T> Response<T> ok(T data, Pagination pagination) {
        return new Response<>(Meta._200, data, pagination);
    }

    public static <T> Response<T> ng(Meta meta) {
        return new Response<>(meta);
    }

    public static <T> Response<T> newInstance(Meta meta, T data) {
        return new Response<>(meta, data, null);
    }

    public static <T> Response<T> newInstance(Meta meta, T data, Pagination pagination) {
        return new Response<>(meta, data, pagination);
    }

    private Meta meta;
    private T data;
    private Pagination pagination;

    private Response(Meta meta) {
        this.meta = meta;
    }

    private Response(Meta meta, T data, Pagination pagination) {
        this.meta = meta;
        this.data = data;
        this.pagination = pagination;
    }

    public Meta getMeta() {
        return this.meta;
    }

    public T getData() {
        return this.data;
    }

    public Pagination getPagination() {
        return this.pagination;
    }
}

